﻿using System;
using System.Data;

namespace BizElements.Core
{
    /// <summary>Transforms single record to and from object array and ADO.NET DataRow object.</summary>
    public interface IRecordTransformer
    {
        /// <summary>Gets or sets the entity that is transformed by transformer.</summary>
        IEntity TransformedEntity { get; set; }

        /// <summary>Initializes entity members with data stored in the given DataRow.</summary>
        /// <param name="row">DataRow with the required columns.</param>
        void FromDataRow(DataRow row);

        /// <summary>Initializes entity members with data stored in the given DataRow.</summary>
        /// <param name="row">DataRow with all or some of the columns defined in meta data.</param>
        /// <param name="fieldMetadata"><see cref="IDbTable"/> meta data object which links ADO.NET row columns to entity properties.</param>
        /// <remarks>This method, when used in combination with <see cref="IDbTable"/> objects that contain columns with
        /// prefixed aliases, enables you to initialize multiple entities that belong to different tables with data from a single DataRow.</remarks>
        void FromDataRow(DataRow row, IDbTable fieldMetadata);

        /// <summary>Creates an array of objects containing entity data suitable for copying and importing into <see cref="DataTable"/> </summary>	
        /// <returns>Entity values.</returns>	
        object[] ToObjectArray();

        /// <summary>Initializes entity members with the given values.</summary>
        /// <param name="entityValues">Array with the required values.</param>	
        void FromObjectArray(object[] entityValues);
    }
}
